<%@ Page Language="C#" %>
<script runat="server">
    protected string script = @"<script type=""text/javascript"">window.setTimeout(""RedirectUrl(window.location{0})"", 1000);</" + "script>";
    protected string outString = @"<div style=\""Z-INDEX: 199; MARGIN:0 auto; WIDTH: 500px; POSITION: relative; TOP: 150px; BACKGROUND-COLOR: #fff;height:200!important;height:300px;padding-top:100px\""><div style=\""padding-bottom:20px;font-size:26px;text-align:left;WIDTH: 300px; margin:0 auto\"">Uploading...</div><div style=\""BORDER-RIGHT: #e2007b 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: #e2007b 1px solid; PADDING-LEFT: 1px; FONT-SIZE: 1px; PADDING-BOTTOM: 1px; BORDER-LEFT: #e2007b 1px solid; WIDTH: 300px; PADDING-TOP: 1px; BORDER-BOTTOM: #e2007b 1px solid; HEIGHT: 25px;text-align:left; margin:0 auto\""><div style=\""HEIGHT: 100%; BACKGROUND-COLOR: #e2007b;width:{0}; color:#333;text-align:left\"" >{1}</div></div></div>";
    protected String scrpit1 = @"<script type=""text/javascript"">parent.window.SetProcessDiv(""{0}"");</" + "script>";
    protected String scrpit2 = @"<script type=""text/javascript"">parent.window.document.getElementById('uploadFileSize').value='1';</" + "script>";
    protected override void OnLoad(EventArgs e)
    {
         if ((!string.IsNullOrEmpty(Request["C"])) || (!string.IsNullOrEmpty(Request["C1"])))
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "dd", scrpit1.Replace("{0}", "C"));
            return;
        }
        if (!string.IsNullOrEmpty(Request["LongxinUploadGUID"]))
        {
            string tmpErr = (string)Application["_Error_" + Request["LongxinUploadGUID"]];
            if (tmpErr!=null&&(tmpErr.StartsWith("NL")||tmpErr.StartsWith("ML")))
            {
                Application.Remove("_Error_" + Request["LongxinUploadGUID"]);
                Page.ClientScript.RegisterStartupScript(this.GetType(), "dd", scrpit1.Replace("{0}", tmpErr));
                return;
            }
            Lx.Progress obj = (Lx.Progress)Application["_UploadGUID_" + Request["LongxinUploadGUID"]];
            if (obj != null)
            {
                if (!(obj.UploadStatus == Lx.Progress.UploadStatusEnum.Completed))
                {
                    obj.RemoveUploadID();
                    Double k = (double)obj.FileLength / 1048576;
                    if (k > 1024*1024*5)
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "setFileSize", scrpit2);
                    }
                    string a = ((double)obj.ReceivedLength / (double)obj.FileLength).ToString("P");
                    
                    string b = String.Format("{0}(Size:{1}M)", a, k.ToString("#####.##"));
                    
                    if (((double)obj.ReceivedLength / (double)obj.FileLength) < 0.99)
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "refresh", script.Replace("{0}", ""));
                    }
                    else
                    {
                        obj.RemoveUploadID();
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "refresh", script.Replace("{0}", "+'&C=1'"));
                    }
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "dd", scrpit1.Replace("{0}", outString.Replace("{0}",a).Replace("{1}",b)));
                }
                else
                {
                    obj.RemoveUploadID();
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "refresh", script.Replace("{0}", "+'&C1=1'"));
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "dd", scrpit1.Replace("{0}", outString.Replace("{0}", "100%").Replace("{1}", "Complete")));
                }
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "refresh", script.Replace("{0}", ""));
            }
        }
    }
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
	<head>
		<title>CustomProgress</title>
		<script type="text/javascript">
		 function  RedirectUrl(strUrl)
		 {
		    window.location.href = strUrl;
		 }
		</script>
	</head>
	<body>
		<form id="form1" runat="server"></form>
	</body>
</html>